<?php 
	error_reporting(E_ALL^E_NOTICE); //取消警告显示
	include $_SERVER['DOCUMENT_ROOT']."/common/fun.php";
  include "../conn.php";//https
  header('Content-type:application/json');
  date_default_timezone_set("Asia/Shanghai");

  //获取用户ID
  $userid = get_post_para('userid',true);

  if (!$con)
  {
    $myArray["resault"]='fail';
    $myArray["error"]='数据库读取错误！';
    $json = json_encode($myArray,JSON_UNESCAPED_UNICODE);
    echo $json;
  }
  else
  {
     $myArray["resault"] = 'success';
     $result = mysqli_query($con, "SELECT * FROM device WHERE userid = '$userid' ");
     $myArray["num"] = $result->num_rows;
       while ($row = mysqli_fetch_array($result)) {
         $indexArray = null;
         $indexArray["id"]=$row['id'];
         $indexArray["userid"]=$row['userid'];
         $indexArray["deviceid"]=$row['deviceid'];
         $indexArray["name"]=$row['name'];
         $indexArray["pic"]=$row['pic'];
         $indexArray["online"]=$row['online'];
         $indexArray["created"]=$row['created'];
         $indexArray["ip"]=$row['ip'];
         $indexArray["port"]=$row['port'];
        $myArray["list"][]=$indexArray;
      }
      // mysqli_close($con);
                 // print_r($myArray); 
      $json = json_encode($myArray,JSON_UNESCAPED_UNICODE);
      echo $json;
  }
?>

